package IO;

import java.io.*;

public class SeekFile {
//    按照指定文件名与路径，查找文件
    public static void main(String[] args) throws IOException {
        search("F:", "jpg");

    }

    public static void search(String url, String end) {
        File dir = new File(url);

        File[] file = dir.listFiles();

        if (file != null && file.length > 0) {
            for (File fs : file) {
                if (fs.isDirectory()) {
                    search(fs.getAbsolutePath(), end);
                } else if (fs.getName().endsWith("." + end)) {
                    System.out.println(fs.getAbsolutePath());
                }

            }
        }

    }

}